import 'package:kepu/generated/json/base/json_convert_content.dart';
import 'package:kepu/model/plant_list_by_type_entity.dart';

PlantListByTypeEntity $PlantListByTypeEntityFromJson(
    Map<String, dynamic> json) {
  final PlantListByTypeEntity plantListByTypeEntity = PlantListByTypeEntity();
  final int? code = jsonConvert.convert<int>(json['code']);
  if (code != null) {
    plantListByTypeEntity.code = code;
  }
  final String? msg = jsonConvert.convert<String>(json['msg']);
  if (msg != null) {
    plantListByTypeEntity.msg = msg;
  }
  final List<PlantListByTypeData>? data = (json['data'] as List<dynamic>?)
      ?.map(
          (e) =>
      jsonConvert.convert<PlantListByTypeData>(e) as PlantListByTypeData)
      .toList();
  if (data != null) {
    plantListByTypeEntity.data = data;
  }
  return plantListByTypeEntity;
}

Map<String, dynamic> $PlantListByTypeEntityToJson(
    PlantListByTypeEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['code'] = entity.code;
  data['msg'] = entity.msg;
  data['data'] = entity.data.map((v) => v.toJson()).toList();
  return data;
}

extension PlantListByTypeEntityExtension on PlantListByTypeEntity {
  PlantListByTypeEntity copyWith({
    int? code,
    String? msg,
    List<PlantListByTypeData>? data,
  }) {
    return PlantListByTypeEntity()
      ..code = code ?? this.code
      ..msg = msg ?? this.msg
      ..data = data ?? this.data;
  }
}

PlantListByTypeData $PlantListByTypeDataFromJson(Map<String, dynamic> json) {
  final PlantListByTypeData plantListByTypeData = PlantListByTypeData();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    plantListByTypeData.id = id;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    plantListByTypeData.name = name;
  }
  final String? image = jsonConvert.convert<String>(json['image']);
  if (image != null) {
    plantListByTypeData.image = image;
  }
  final String? description = jsonConvert.convert<String>(json['description']);
  if (description != null) {
    plantListByTypeData.description = description;
  }
  final String? region = jsonConvert.convert<String>(json['region']);
  if (region != null) {
    plantListByTypeData.region = region;
  }
  final String? type = jsonConvert.convert<String>(json['type']);
  if (type != null) {
    plantListByTypeData.type = type;
  }
  return plantListByTypeData;
}

Map<String, dynamic> $PlantListByTypeDataToJson(PlantListByTypeData entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['name'] = entity.name;
  data['image'] = entity.image;
  data['description'] = entity.description;
  data['region'] = entity.region;
  data['type'] = entity.type;
  return data;
}

extension PlantListByTypeDataExtension on PlantListByTypeData {
  PlantListByTypeData copyWith({
    int? id,
    String? name,
    String? image,
    String? description,
    String? region,
    String? type,
  }) {
    return PlantListByTypeData()
      ..id = id ?? this.id
      ..name = name ?? this.name
      ..image = image ?? this.image
      ..description = description ?? this.description
      ..region = region ?? this.region
      ..type = type ?? this.type;
  }
}